import java.io.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class test4 {
    static boolean nowIsPlayer = true;
    static int lastx = -123456789, lasty = -123456789;
    static boolean computerPlayChessSign = true;
    static int piecesPlay = 0;
    static int otherFirstPlayer = 1;
    static int otherSecondPlayer = 2;
    static int otherThirdPlayer = 3;
    static String piecesColor[] = {"r1", "y1", "b1", "g1"};
    static String notPosition[] = {"r2", "y2", "b2", "g2"};
    static String canPosition[] = {"r3", "y3", "b3", "g3"};
    static String color[] = {"red", "yellow", "blue", "green"};
    static String[][][] con = new String[22][8][8];
    static String[][] boxIndex = new String[21][21];
    static int[] leftNum = new int[22];
    static int[] rightNum = new int[22];
    static int[] upperNum = new int[22];
    static int[] lowerNum = new int[22];
    static boolean[] determine = new boolean[22];
    static int choose = 0;
    static boolean first = true;
    static boolean[][] comUsed = new boolean[4][22];
    static int boxLength = 800;
    static int gridLength = 40;
    static String file_path = "E:\\java\\Test";
    static String file_name = "answer.txt";
    static String[][][] replay = new String[100][21][21];
    static int rnum = 0;

    public static void main(String[] args) {
        initComputerUsed();
        initChessBoard();
        initChessPlay();
        move();
        display();
    }

    private static void display() {
        String s;
        s = convert(replay);
        writeFileContent(file_path + "\\" + file_name, s);
        String answer = readFileContent(file_path + "\\" + file_name);
        System.out.println(answer);
    }

    public static String readFileContent(String fileName) {
        File file = new File(fileName);
        BufferedReader reader = null;
        StringBuffer sbf = new StringBuffer();
        try {
            reader = new BufferedReader(new FileReader(file));
            String tempStr;
            while ((tempStr = reader.readLine()) != null) {
                sbf.append(tempStr);
            }
            reader.close();
            return sbf.toString();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
        return sbf.toString();
    }

    public static void writeFileContent(String fileName, String content) {
        try {
            File file = new File(fileName);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(content);
            bw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static String convert(String[][][] chess) {
        String m = "";
        for (int i = 0; i < rnum; i++) {
            if (i != 0) {
                m += "|";
            }
            for (int j = 0; j < chess[i].length; j++) {
                if (j != 0) {
                    m += "#";
                }
                for (int x = 0; x < chess[i][j].length; x++) {
                    if (x != 0) {
                        m += ",";
                    }
                    m += chess[i][j][x];
                }
            }
        }
        return m;
    }

    private static void myreplay(String[][] chess) {
        for (int i = 0; i < chess.length; i++) {
            for (int j = 0; j < chess[i].length; j++) {
                replay[rnum][i][j] = chess[i][j];
            }
        }
        rnum++;
    }

    private static void move() {
        int j = 0;
        int[] a = new int[4];
        for (int i = 0; i < 4; i++) {
            a[i] = 0;
        }
        int i = 0;
        while (true) {
            if (i == 0) {
                if (a[i] != 1) {
                    a = computerPlay1(i, a);
                }
                if (a[i] != 1) {
                    myreplay(boxIndex);
                }
            } else if (i == 1) {
                if (a[i] != 1) {
                    a = computerPlay2(i, a);
                }
                if (a[i] != 1) {
                    myreplay(boxIndex);
                }
            } else if (i == 2) {
                if (a[i] != 1) {
                    a = computerPlay3(i, a);
                }
                if (a[i] != 1) {
                    myreplay(boxIndex);
                }
            } else if (i == 3) {
                if (a[i] != 1) {
                    a = computerPlay4(i, a);
                }
                if (a[i] != 1) {
                    myreplay(boxIndex);
                }
            }
            i++;
            i %= 4;
            j++;
            if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1) {
                break;
            }
        }
    }

    private static int[] Xuan90Y(int[] tempZ, int[] disCenterY) {
        int[] tempY = new int[5];
        for (int i = 0; i < tempZ.length; ++i) {
            if (tempZ[i] == 0) {
                tempY[i] = tempZ[i];
            } else if (disCenterY[i] == 0) {
                tempY[i] = -tempZ[i];
            } else {
                tempY[i] = -tempZ[i];
            }
        }
        return tempY;
    }

    private static int[] Xuan90X(int[] disCenterX, int[] disCenterY) {
        int[] tempX = new int[5];
        for (int i = 0; i < disCenterX.length; ++i) {
            tempX[i] = disCenterY[i];
        }
        return tempX;
    }

    private static int[] LeftAndRightY(int[] tempZ, int[] disCenterY) {
        int[] tempY = new int[5];
        for (int i = 0; i < tempZ.length; ++i) {
            if (disCenterY[i] == 0) tempY[i] = disCenterY[i];
            else tempY[i] = -disCenterY[i];
        }
        return tempY;
    }

    private static int[] LeftAndRightX(int[] disCenterX, int[] disCenterY) {
        int[] tempX = new int[5];
        for (int i = 0; i < disCenterX.length; ++i) {
            tempX[i] = disCenterX[i];
        }
        return tempX;
    }

    private static void updateComBoxIndex(int no) {
        for (int i = 1; i <= 20; ++i) {
            for (int j = 1; j <= 20; ++j) {
                if (boxIndex[i][j] == piecesColor[no]) {
                    if (i - 1 >= 1 && i - 1 <= 20 && j - 1 >= 1 && j - 1 <= 20) {
                        if (boxIndex[i - 1][j - 1] == "0") {
                            boxIndex[i - 1][j - 1] = canPosition[no];
                        }
                    }
                    if (i - 1 >= 1 && i - 1 <= 20 && j + 1 >= 1 && j + 1 <= 20) {
                        if (boxIndex[i - 1][j + 1] == "0") {
                            boxIndex[i - 1][j + 1] = canPosition[no];
                        }
                    }
                    if (i + 1 >= 1 && i + 1 <= 20 && j - 1 >= 1 && j - 1 <= 20) {
                        if (boxIndex[i + 1][j - 1] == "0") {
                            boxIndex[i + 1][j - 1] = canPosition[no];
                        }
                    }
                    if (i + 1 >= 1 && i + 1 <= 20 && j + 1 >= 1 && j + 1 <= 20) {
                        if (boxIndex[i + 1][j + 1] == "0") {
                            boxIndex[i + 1][j + 1] = canPosition[no];
                        }
                    }
                }
            }
        }
        for (int i = 1; i <= 20; ++i) {
            for (int j = 1; j <= 20; ++j) {
                if (boxIndex[i][j] == piecesColor[no]) {
                    if (i + 1 >= 1 && i + 1 <= 20) {
                        if (boxIndex[i + 1][j] == "0" || boxIndex[i + 1][j] == canPosition[no]) {
                            boxIndex[i + 1][j] = notPosition[no];
                        }
                    }
                    if (i - 1 >= 1 && i - 1 <= 20) {
                        if (boxIndex[i - 1][j] == "0" || boxIndex[i - 1][j] == canPosition[no]) {
                            boxIndex[i - 1][j] = notPosition[no];
                        }
                    }
                    if (j - 1 >= 1 && j - 1 <= 20) {
                        if (boxIndex[i][j - 1] == "0" || boxIndex[i][j - 1] == canPosition[no]) {
                            boxIndex[i][j - 1] = notPosition[no];
                        }
                    }
                    if (j + 1 >= 1 && j + 1 <= 20) {
                        if (boxIndex[i][j + 1] == "0" || boxIndex[i][j + 1] == canPosition[no]) {
                            boxIndex[i][j + 1] = notPosition[no];
                        }
                    }
                }
            }
        }
    }

    private static void initChessPlay() {
        for (int i = 0; i <= 21; i++) {
            leftNum[i] = 0;
            rightNum[i] = 0;
            upperNum[i] = 0;
            lowerNum[i] = 0;
            determine[i] = false;
            for (int j = 0; j < 8; j++) {
                for (int k = 0; k < 8; k++) {
                    con[i][j][k] = "0";
                }
            }
        }
        for (int i = 1; i <= 21; i++) {
            switch (i) {
                case 1:
                    con[i][4][4] = piecesColor[piecesPlay];
                    con[i][3][4] = con[i][4][3] = con[i][4][5] = con[i][5][4] = notPosition[piecesPlay];
                    con[i][3][3] = con[i][3][5] = con[i][5][3] = con[i][5][5] = canPosition[piecesPlay];
                    leftNum[i] = 0;
                    rightNum[i] = 0;
                    upperNum[i] = 0;
                    lowerNum[i] = 0;
                    break;
                case 2:
                    con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][3][4] = con[i][3][5] = con[i][4][3] = con[i][4][6] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][3][3] = con[i][3][6] = con[i][5][3] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 0;
                    rightNum[i] = 1;
                    upperNum[i] = 0;
                    lowerNum[i] = 0;
                    break;
                case 3:
                    con[i][4][3] = con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][3][3] = con[i][3][4] = con[i][3][5] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][3][2] = con[i][3][6] = con[i][5][2] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 0;
                    lowerNum[i] = 0;
                    break;
                case 4:
                    con[i][3][4] = con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][2][4] = con[i][3][3] = con[i][3][5] = con[i][4][3] = con[i][4][6] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][2][3] = con[i][2][5] = con[i][3][6] = con[i][5][3] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 0;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 5:
                    con[i][4][3] = con[i][4][4] = con[i][4][5] = con[i][4][6] = piecesColor[piecesPlay];
                    con[i][3][3] = con[i][3][4] = con[i][3][5] = con[i][3][6] = con[i][4][2] = con[i][4][7] = con[i][5][3] = con[i][5][4] = con[i][5][5] = con[i][5][6] = notPosition[piecesPlay];
                    con[i][3][2] = con[i][3][7] = con[i][5][2] = con[i][5][7] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 2;
                    upperNum[i] = 0;
                    lowerNum[i] = 0;
                    break;
                case 6:
                    con[i][3][3] = con[i][4][3] = con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][3][2] = con[i][3][4] = con[i][3][5] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][4] = con[i][3][6] = con[i][5][2] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 7:
                    con[i][3][4] = con[i][4][3] = con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][2][4] = con[i][3][3] = con[i][3][5] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][2][3] = con[i][2][5] = con[i][3][2] = con[i][3][6] = con[i][5][2] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 8:
                    con[i][3][3] = con[i][3][4] = con[i][4][3] = con[i][4][4] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][2][4] = con[i][3][2] = con[i][3][5] = con[i][4][2] = con[i][4][5] = con[i][5][3] = con[i][5][4] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][5] = con[i][5][2] = con[i][5][5] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 0;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 9:
                    con[i][3][3] = con[i][3][4] = con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][2][4] = con[i][3][2] = con[i][3][5] = con[i][4][3] = con[i][4][6] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][5] = con[i][3][6] = con[i][4][2] = con[i][5][3] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 10:
                    con[i][4][2] = con[i][4][3] = con[i][4][4] = con[i][4][5] = con[i][4][6] = piecesColor[piecesPlay];
                    con[i][3][2] = con[i][3][3] = con[i][3][4] = con[i][3][5] = con[i][3][6] = con[i][4][1] = con[i][4][7] = con[i][5][2] = con[i][5][3] = con[i][5][4] = con[i][5][5] = con[i][5][6] = notPosition[piecesPlay];
                    con[i][3][1] = con[i][3][7] = con[i][5][1] = con[i][5][7] = canPosition[piecesPlay];
                    leftNum[i] = 2;
                    rightNum[i] = 2;
                    upperNum[i] = 0;
                    lowerNum[i] = 0;
                    break;
                case 11:
                    con[i][3][3] = con[i][4][3] = con[i][4][4] = con[i][4][5] = con[i][4][6] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][3][2] = con[i][3][4] = con[i][3][5] = con[i][3][6] = con[i][4][2] = con[i][4][7] = con[i][5][3] = con[i][5][4] = con[i][5][5] = con[i][5][6] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][4] = con[i][3][7] = con[i][5][2] = con[i][5][7] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 2;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 12:
                    con[i][3][4] = con[i][4][3] = con[i][4][4] = con[i][4][5] = con[i][4][6] = piecesColor[piecesPlay];
                    con[i][2][4] = con[i][3][3] = con[i][3][5] = con[i][3][6] = con[i][4][2] = con[i][4][7] = con[i][5][3] = con[i][5][4] = con[i][5][5] = con[i][5][6] = notPosition[piecesPlay];
                    con[i][2][3] = con[i][2][5] = con[i][3][2] = con[i][3][7] = con[i][5][2] = con[i][5][7] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 2;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 13:
                    con[i][3][4] = con[i][4][3] = con[i][4][4] = con[i][4][5] = con[i][5][4] = piecesColor[piecesPlay];
                    con[i][2][4] = con[i][3][3] = con[i][3][5] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][5] = con[i][6][4] = notPosition[piecesPlay];
                    con[i][2][3] = con[i][2][5] = con[i][3][2] = con[i][3][6] = con[i][5][2] = con[i][5][6] = con[i][6][3] = con[i][6][5] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 1;
                    break;
                case 14:
                    con[i][3][3] = con[i][3][4] = con[i][4][3] = con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][2][4] = con[i][3][2] = con[i][3][5] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][5] = con[i][3][6] = con[i][5][2] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 15:
                    con[i][3][3] = con[i][3][5] = con[i][4][3] = con[i][4][4] = con[i][4][5] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][2][5] = con[i][3][2] = con[i][3][4] = con[i][3][6] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][4] = con[i][5][5] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][4] = con[i][2][6] = con[i][5][2] = con[i][5][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 16:
                    con[i][3][4] = con[i][4][4] = con[i][5][3] = con[i][5][4] = con[i][5][5] = piecesColor[piecesPlay];
                    con[i][2][4] = con[i][3][3] = con[i][3][5] = con[i][4][3] = con[i][4][5] = con[i][5][2] = con[i][5][6] = con[i][6][3] = con[i][6][4] = con[i][6][5] = notPosition[piecesPlay];
                    con[i][2][3] = con[i][2][5] = con[i][4][2] = con[i][4][6] = con[i][6][2] = con[i][6][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 1;
                    break;
                case 17:
                    con[i][3][3] = con[i][4][3] = con[i][4][4] = con[i][4][5] = con[i][5][4] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][3][2] = con[i][3][4] = con[i][3][5] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][5] = con[i][6][4] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][4] = con[i][3][6] = con[i][5][2] = con[i][5][6] = con[i][6][3] = con[i][6][5] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 1;
                    break;
                case 18:
                    con[i][3][3] = con[i][4][3] = con[i][4][4] = con[i][4][5] = con[i][5][5] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][3][2] = con[i][3][4] = con[i][3][5] = con[i][4][2] = con[i][4][6] = con[i][5][3] = con[i][5][4] = con[i][5][6] = con[i][6][5] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][4] = con[i][3][6] = con[i][5][2] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 1;
                    break;
                case 19:
                    con[i][3][3] = con[i][4][3] = con[i][4][4] = con[i][5][4] = con[i][5][5] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][3][2] = con[i][3][4] = con[i][4][2] = con[i][4][5] = con[i][5][3] = con[i][5][6] = con[i][6][4] = con[i][6][5] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][4] = con[i][3][5] = con[i][4][6] = con[i][5][2] = con[i][6][3] = con[i][6][6] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 1;
                    upperNum[i] = 1;
                    lowerNum[i] = 1;
                    break;
                case 20:
                    con[i][3][3] = con[i][3][4] = con[i][4][4] = con[i][4][5] = con[i][4][6] = piecesColor[piecesPlay];
                    con[i][2][3] = con[i][2][4] = con[i][3][2] = con[i][3][5] = con[i][3][6] = con[i][4][3] = con[i][4][7] = con[i][5][4] = con[i][5][5] = con[i][5][6] = notPosition[piecesPlay];
                    con[i][2][2] = con[i][2][5] = con[i][3][7] = con[i][4][2] = con[i][5][3] = con[i][5][7] = canPosition[piecesPlay];
                    leftNum[i] = 1;
                    rightNum[i] = 2;
                    upperNum[i] = 1;
                    lowerNum[i] = 0;
                    break;
                case 21:
                    con[i][2][4] = con[i][3][4] = con[i][4][4] = con[i][4][5] = con[i][4][6] = piecesColor[piecesPlay];
                    con[i][1][4] = con[i][2][3] = con[i][2][5] = con[i][3][3] = con[i][3][5] = con[i][3][6] = con[i][4][3] = con[i][4][7] = con[i][5][4] = con[i][5][5] = con[i][5][6] = notPosition[piecesPlay];
                    con[i][1][3] = con[i][1][5] = con[i][3][7] = con[i][5][3] = con[i][5][7] = canPosition[piecesPlay];
                    leftNum[i] = 0;
                    rightNum[i] = 2;
                    upperNum[i] = 2;
                    lowerNum[i] = 0;
                    break;
            }
        }
    }

    private static void initChessBoard() {
        for (int i = 0; i < 21; i++) {
            for (int j = 0; j < 21; j++) {
                boxIndex[i][j] = "0";
            }
        }
        boxIndex[20][1] = "r3";
        boxIndex[20][20] = "y3";
        boxIndex[1][20] = "b3";
        boxIndex[1][1] = "g3";
    }

    private static void initComputerUsed() {
        for (int i = 0; i <= 3; ++i) {
            for (int j = 0; j <= 21; ++j) {
                comUsed[i][j] = false;
            }
        }
    }

    private static int[] computerPlay(int no, int[] a) {
        updateComBoxIndex(no);
        boolean flag = false;
        Map<Integer, Integer> comCanLet = new HashMap<Integer, Integer>();
        for (int i = 1; i <= 20; ++i) {
            for (int j = 1; j <= 20; ++j) {
                if (boxIndex[i][j] == canPosition[no]) {
                    comCanLet.put(i, j);
                }
            }
        }
        List<Map.Entry<Integer, Integer>> list = new ArrayList<Map.Entry<Integer, Integer>>(comCanLet.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
            public int compare(Map.Entry<Integer, Integer> a, Map.Entry<Integer, Integer> b) {
                if (Math.abs(a.getKey() - a.getValue()) > Math.abs(b.getKey() - b.getValue())) {
                    return 1;
                } else if (Math.abs(a.getKey() - a.getValue()) < Math.abs(b.getKey() - b.getValue())) {
                    return -1;
                } else return 0;
            }
        });
        int ComChoose;
        for (int i = 0; i < list.size(); ++i) {
            int x = list.get(i).getKey(), y = list.get(i).getValue();
            for (int comi = 0; comi < 6; ++comi) {
                int[] DisCenterX = new int[5];
                int[] DisCenterY = new int[5];
                ;
                ComChoose = (int) (Math.floor(10 + Math.random() * (21 - 10 + 1)));
                if (comUsed[no][ComChoose] == true) {
                    continue;
                }
                switch (ComChoose) {
                    case 10:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = 0;
                        DisCenterY[4] = -2;
                        break;
                    case 11:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 12:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 13:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 14:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = -1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 15:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 1;
                        break;
                    case 16:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                    case 17:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 18:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 19:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 1;
                        DisCenterY[1] = 0;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 20:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 21:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                }
                for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                    for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                        if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) {
                            for (int direct = 1; direct <= 8; ++direct) {
                                if (direct == 5) {
                                    int[] tempZ;
                                    tempZ = DisCenterX;
                                    DisCenterX = LeftAndRightX(DisCenterX, DisCenterY);
                                    DisCenterY = LeftAndRightY(tempZ, DisCenterY);
                                }
                                int[] tempZ = new int[5];
                                tempZ = DisCenterX;
                                DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                DisCenterY = Xuan90Y(tempZ, DisCenterY);
                                boolean flagGai = false;
                                int illegal = 0;
                                for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                    int tempx = qzx + DisCenterX[DCXi];
                                    int tempy = qzy + DisCenterY[DCXi];
                                    if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                        if (tempx == x && tempy == y) {
                                            flagGai = true;
                                        }
                                        if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                            if ((tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" || (boxIndex[tempx][tempy + 1] != piecesColor[no])))) && (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" || (boxIndex[tempx][tempy - 1] != piecesColor[no])))) && (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" || (boxIndex[tempx + 1][tempy] != piecesColor[no])))) && (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" || (boxIndex[tempx - 1][tempy] != piecesColor[no]))))) {
                                                ;
                                            }
                                        } else {
                                            illegal++;
                                        }
                                    } else {
                                        illegal++;
                                    }
                                }
                                if (flagGai && illegal == 0) {
                                    for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                        int tempx = qzx + DisCenterX[DCXi];
                                        int tempy = qzy + DisCenterY[DCXi];
                                        boxIndex[tempx][tempy] = piecesColor[no];
                                    }
                                    comUsed[no][ComChoose] = true;
                                    return a;
                                }
                            }
                        }
                    }
                }
            }
            if (!flag) {
                for (ComChoose = 21; ComChoose >= 1; --ComChoose) {
                    int[] DisCenterX = new int[5];
                    int[] DisCenterY = new int[5];
                    if (comUsed[no][ComChoose] == false) {
                        switch (ComChoose) {
                            case 1:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                break;
                            case 2:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                break;
                            case 3:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                break;
                            case 4:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                break;
                            case 5:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                break;
                            case 6:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 7:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 8:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = -1;
                                DisCenterY[1] = -1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 9:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 10:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = 0;
                                DisCenterY[4] = -2;
                                break;
                            case 11:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 12:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 13:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 14:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 15:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 1;
                                break;
                            case 16:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                            case 17:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 18:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 19:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 1;
                                DisCenterY[1] = 0;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 20:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 21:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                        }
                        for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                            for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                                if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) {
                                    for (int direct = 1; direct <= 4; ++direct) {
                                        int tempZ[] = new int[5];
                                        tempZ = DisCenterX;
                                        DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                        DisCenterY = Xuan90Y(tempZ, DisCenterY);
                                        boolean flagGai = false;
                                        int illegal = 0;
                                        for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                            int tempx = qzx + DisCenterX[DCXi];
                                            int tempy = qzy + DisCenterY[DCXi];
                                            if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                                if (tempx == x && tempy == y) {
                                                    flagGai = true;
                                                }
                                                if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                                    if ((tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" || (boxIndex[tempx][tempy + 1] != piecesColor[no])))) && (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" || (boxIndex[tempx][tempy - 1] != piecesColor[no])))) && (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" || (boxIndex[tempx + 1][tempy] != piecesColor[no])))) && (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" || (boxIndex[tempx - 1][tempy] != piecesColor[no]))))) {
                                                        ;
                                                    }
                                                } else {
                                                    illegal++;
                                                }
                                            } else {
                                                illegal++;
                                            }
                                        }
                                        if (flagGai && illegal == 0) {
                                            for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                                int tempx = qzx + DisCenterX[DCXi];
                                                int tempy = qzy + DisCenterY[DCXi];
                                                boxIndex[tempx][tempy] = piecesColor[no];
                                            }
                                            comUsed[no][ComChoose] = true;
                                            return a;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        a[no] = 1;
        return a;
    }

    private static int[] computerPlay1(int no, int[] a) {
        updateComBoxIndex(no);  //更新棋盘，更新xxx2 xxx3的点

        boolean flag = false;
        Map<Integer, Integer> comCanLet = new HashMap<Integer, Integer>();//电脑编号no能下的位置
        //找位置
        for (int i = 1; i <= 20; ++i) {
            for (int j = 1; j <= 20; ++j) {
                if (boxIndex[i][j] == canPosition[no]) {
                    //console.log(i,j);
                    comCanLet.put(i, j);
//                    comCanLet.push({x:i,y:j});
                }
            }
        }
        //排序
        List<Map.Entry<Integer, Integer>> list = new ArrayList<Map.Entry<Integer, Integer>>(comCanLet.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
            //升序排序
            public int compare(Map.Entry<Integer, Integer> a,
                               Map.Entry<Integer, Integer> b) {
                int a1 = Math.abs(a.getKey() - a.getValue());
                int a2 = Math.abs(b.getKey() - b.getValue());
                if (a1 > a2) {
                    return 1;
                } else if (a1 < a2) {
                    return -1;
                } else return 0;
            }

        });
        // console.log(comCanLet);
        int ComChoose;//电脑选择棋子的编号
        //按位置逐一枚举
        for (int i = 0; i < list.size(); ++i) {
            int x = list.get(i).getKey(), y = list.get(i).getValue();
            for (int comi = 0; comi < 6; ++comi) {
                int[] DisCenterX = new int[5];
                int[] DisCenterY = new int[5];
                ;

                ComChoose = (int) (Math.floor(10 + Math.random() * (21 - 10 + 1)));
                //console.log('电脑选择的棋子' + ComChoose);

                if (comUsed[no][ComChoose] == true) {
                    continue;
                }

                switch (ComChoose) {
                    case 10:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = 0;
                        DisCenterY[4] = -2;
                        break;
                    case 11:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 12:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 13:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 14:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = -1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 15:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 1;
                        break;
                    case 16:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                    case 17:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 18:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 19:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 1;
                        DisCenterY[1] = 0;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 20:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 21:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                }
                //棋子中心点,从中心点扩展标记棋子
                for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                    for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                        //console.log('中心点'+qzx+' '+qzy);
                        if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法

                            //111111111原来棋子的方向顺时针旋转
                            for (int direct = 1; direct <= 8; ++direct) {
                                if (direct == 5) { //左右旋转尝试
                                    int[] tempZ;
                                    tempZ = DisCenterX;
                                    DisCenterX = LeftAndRightX(DisCenterX, DisCenterY);
                                    DisCenterY = LeftAndRightY(tempZ, DisCenterY);//旋转90度
                                }

                                int[] tempZ = new int[5];
                                tempZ = DisCenterX;
                                DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                boolean flagGai = false;//是否覆盖选择的x,y点
                                int illegal = 0;//中心点扩展棋子违规的点的数量


                                for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                    int tempx = qzx + DisCenterX[DCXi];
                                    int tempy = qzy + DisCenterY[DCXi];
                                    //console.log(tempx + ' ' + tempy);
                                    if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                        if (tempx == x && tempy == y) {
                                            flagGai = true;
                                        }
                                        if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                            if (
                                                    (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                            (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                            &&
                                                            (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                    (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                            &&
                                                            (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                    (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                            &&
                                                            (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                    (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                            ) {
                                                ;
                                            }
                                        } else {
                                            illegal++;
                                        }
                                    } else {
                                        illegal++;
                                    }
                                }

                                //能放!!!!!!!!!!!!!!!
                                if (flagGai && illegal == 0) {
                                    for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                        int tempx = qzx + DisCenterX[DCXi];
                                        int tempy = qzy + DisCenterY[DCXi];
                                        boxIndex[tempx][tempy] = piecesColor[no];
                                    }
                                    //画上，直接退出
                                    comUsed[no][ComChoose] = true;

                                    // drawChessBoard(boxIndex);
                                    return a;
                                }
                            }

                            //222222222左右翻转后，再顺时针旋转尝试  TODO

                        }
                    }
                }
            }
            //>>>>>>>>>>>>>>>>>>>>>>>>第二部分,如果随机方案不成功，从大到小遍历，谁合适就放谁
            if (!flag) {
                for (ComChoose = 21; ComChoose >= 1; --ComChoose) {
                    //console.log('选择棋子'+ComChoose)
                    int[] DisCenterX = new int[5];
                    int[] DisCenterY = new int[5];
                    if (comUsed[no][ComChoose] == false) {
                        switch (ComChoose) {
                            case 1:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                break;
                            case 2:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                break;
                            case 3:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                break;
                            case 4:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                break;
                            case 5:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                break;
                            case 6:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 7:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 8:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = -1;
                                DisCenterY[1] = -1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 9:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 10:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = 0;
                                DisCenterY[4] = -2;
                                break;
                            case 11:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 12:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 13:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 14:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 15:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 1;
                                break;
                            case 16:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                            case 17:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 18:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 19:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 1;
                                DisCenterY[1] = 0;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 20:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 21:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                        }

                        //棋子中心点,从中心点扩展标记棋子
                        for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                            for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                                //console.log('中心点'+qzx+' '+qzy);
                                if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法
                                    //1111111111原来棋子的方向顺时针旋转
                                    for (int direct = 1; direct <= 4; ++direct) {
                                        int tempZ[] = new int[5];
                                        tempZ = DisCenterX;
                                        DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                        DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                        boolean flagGai = false;//是否覆盖选择的x,y点
                                        int illegal = 0;//中心点扩展棋子违规的点的数量


                                        for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                            int tempx = qzx + DisCenterX[DCXi];
                                            int tempy = qzy + DisCenterY[DCXi];
                                            //console.log(tempx + ' ' + tempy);
                                            if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                                if (tempx == x && tempy == y) {
                                                    flagGai = true;
                                                }
                                                if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                                    if (
                                                            (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                                    (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                            (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                            (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                            (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                                    ) {
                                                        ;
                                                    }
                                                } else {
                                                    illegal++;
                                                }
                                            } else {
                                                illegal++;
                                            }
                                        }

                                        //能放!!!!!!!!!!!!!!!
                                        if (flagGai && illegal == 0) {
                                            for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                                int tempx = qzx + DisCenterX[DCXi];
                                                int tempy = qzy + DisCenterY[DCXi];
                                                boxIndex[tempx][tempy] = piecesColor[no];
                                            }
                                            //画上，直接退出
                                            comUsed[no][ComChoose] = true;

                                            // drawChessBoard(boxIndex);
                                            return a;
                                        }

                                    }

                                    //222222222左右翻转后，再顺时针旋转尝试  TODO

                                }
                            }
                        }
                    }
                }
            }
            //<<=<<<<<<<<<<<<<<<<<==========
        }
        a[no] = 1;
        return a;
    }

    private static int[] computerPlay2(int no, int[] a) {
        updateComBoxIndex(no);  //更新棋盘，更新xxx2 xxx3的点

        boolean flag = false;
        Map<Integer, Integer> comCanLet = new HashMap<Integer, Integer>();//电脑编号no能下的位置
        //找位置
        for (int i = 1; i <= 20; ++i) {
            for (int j = 1; j <= 20; ++j) {
                if (boxIndex[i][j] == canPosition[no]) {
                    //console.log(i,j);
                    comCanLet.put(i, j);
//                    comCanLet.push({x:i,y:j});
                }
            }
        }
        //排序
        List<Map.Entry<Integer, Integer>> list = new ArrayList<Map.Entry<Integer, Integer>>(comCanLet.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
            //升序排序
            public int compare(Map.Entry<Integer, Integer> a,
                               Map.Entry<Integer, Integer> b) {
                int a1 = Math.abs(a.getKey() - a.getValue());
                int a2 = Math.abs(b.getKey() - b.getValue());
                if (a1 > a2) {
                    return 1;
                } else if (a1 < a2) {
                    return -1;
                } else return 0;
            }

        });
        // console.log(comCanLet);
        int ComChoose;//电脑选择棋子的编号
        //按位置逐一枚举
        for (int i = 0; i < list.size(); ++i) {
            int x = list.get(i).getKey(), y = list.get(i).getValue();
            for (int comi = 0; comi < 6; ++comi) {
                int[] DisCenterX = new int[5];
                int[] DisCenterY = new int[5];
                ;

                ComChoose = (int) (Math.floor(10 + Math.random() * (21 - 10 + 1)));
                //console.log('电脑选择的棋子' + ComChoose);

                if (comUsed[no][ComChoose] == true) {
                    continue;
                }

                switch (ComChoose) {
                    case 10:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = 0;
                        DisCenterY[4] = -2;
                        break;
                    case 11:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 12:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 13:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 14:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = -1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 15:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 1;
                        break;
                    case 16:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                    case 17:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 18:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 19:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 1;
                        DisCenterY[1] = 0;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 20:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 21:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                }
                //棋子中心点,从中心点扩展标记棋子
                for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                    for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                        //console.log('中心点'+qzx+' '+qzy);
                        if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法

                            //111111111原来棋子的方向顺时针旋转
                            for (int direct = 1; direct <= 8; ++direct) {
                                if (direct == 5) { //左右旋转尝试
                                    int[] tempZ;
                                    tempZ = DisCenterX;
                                    DisCenterX = LeftAndRightX(DisCenterX, DisCenterY);
                                    DisCenterY = LeftAndRightY(tempZ, DisCenterY);//旋转90度
                                }

                                int[] tempZ = new int[5];
                                tempZ = DisCenterX;
                                DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                boolean flagGai = false;//是否覆盖选择的x,y点
                                int illegal = 0;//中心点扩展棋子违规的点的数量


                                for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                    int tempx = qzx + DisCenterX[DCXi];
                                    int tempy = qzy + DisCenterY[DCXi];
                                    //console.log(tempx + ' ' + tempy);
                                    if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                        if (tempx == x && tempy == y) {
                                            flagGai = true;
                                        }
                                        if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                            if (
                                                    (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                            (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                            &&
                                                            (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                    (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                            &&
                                                            (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                    (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                            &&
                                                            (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                    (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                            ) {
                                                ;
                                            }
                                        } else {
                                            illegal++;
                                        }
                                    } else {
                                        illegal++;
                                    }
                                }

                                //能放!!!!!!!!!!!!!!!
                                if (flagGai && illegal == 0) {
                                    for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                        int tempx = qzx + DisCenterX[DCXi];
                                        int tempy = qzy + DisCenterY[DCXi];
                                        boxIndex[tempx][tempy] = piecesColor[no];
                                    }
                                    //画上，直接退出
                                    comUsed[no][ComChoose] = true;

                                    // drawChessBoard(boxIndex);
                                    return a;
                                }
                            }

                            //222222222左右翻转后，再顺时针旋转尝试  TODO

                        }
                    }
                }
            }
            //>>>>>>>>>>>>>>>>>>>>>>>>第二部分,如果随机方案不成功，从大到小遍历，谁合适就放谁
            if (!flag) {
                for (ComChoose = 21; ComChoose >= 1; --ComChoose) {
                    //console.log('选择棋子'+ComChoose)
                    int[] DisCenterX = new int[5];
                    int[] DisCenterY = new int[5];
                    if (comUsed[no][ComChoose] == false) {
                        switch (ComChoose) {
                            case 1:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                break;
                            case 2:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                break;
                            case 3:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                break;
                            case 4:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                break;
                            case 5:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                break;
                            case 6:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 7:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 8:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = -1;
                                DisCenterY[1] = -1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 9:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 10:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = 0;
                                DisCenterY[4] = -2;
                                break;
                            case 11:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 12:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 13:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 14:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 15:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 1;
                                break;
                            case 16:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                            case 17:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 18:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 19:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 1;
                                DisCenterY[1] = 0;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 20:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 21:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                        }

                        //棋子中心点,从中心点扩展标记棋子
                        for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                            for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                                //console.log('中心点'+qzx+' '+qzy);
                                if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法
                                    //1111111111原来棋子的方向顺时针旋转
                                    for (int direct = 1; direct <= 4; ++direct) {
                                        int tempZ[] = new int[5];
                                        tempZ = DisCenterX;
                                        DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                        DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                        boolean flagGai = false;//是否覆盖选择的x,y点
                                        int illegal = 0;//中心点扩展棋子违规的点的数量


                                        for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                            int tempx = qzx + DisCenterX[DCXi];
                                            int tempy = qzy + DisCenterY[DCXi];
                                            //console.log(tempx + ' ' + tempy);
                                            if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                                if (tempx == x && tempy == y) {
                                                    flagGai = true;
                                                }
                                                if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                                    if (
                                                            (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                                    (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                            (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                            (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                            (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                                    ) {
                                                        ;
                                                    }
                                                } else {
                                                    illegal++;
                                                }
                                            } else {
                                                illegal++;
                                            }
                                        }

                                        //能放!!!!!!!!!!!!!!!
                                        if (flagGai && illegal == 0) {
                                            for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                                int tempx = qzx + DisCenterX[DCXi];
                                                int tempy = qzy + DisCenterY[DCXi];
                                                boxIndex[tempx][tempy] = piecesColor[no];
                                            }
                                            //画上，直接退出
                                            comUsed[no][ComChoose] = true;

                                            // drawChessBoard(boxIndex);
                                            return a;
                                        }

                                    }

                                    //222222222左右翻转后，再顺时针旋转尝试  TODO

                                }
                            }
                        }
                    }
                }
            }
            //<<=<<<<<<<<<<<<<<<<<==========
        }
        a[no] = 1;
        return a;
    }

    private static int[] computerPlay3(int no, int[] a) {
        updateComBoxIndex(no);  //更新棋盘，更新xxx2 xxx3的点

        boolean flag = false;
        Map<Integer, Integer> comCanLet = new HashMap<Integer, Integer>();//电脑编号no能下的位置
        //找位置
        for (int i = 1; i <= 20; ++i) {
            for (int j = 1; j <= 20; ++j) {
                if (boxIndex[i][j] == canPosition[no]) {
                    //console.log(i,j);
                    comCanLet.put(i, j);
//                    comCanLet.push({x:i,y:j});
                }
            }
        }
        //排序
        List<Map.Entry<Integer, Integer>> list = new ArrayList<Map.Entry<Integer, Integer>>(comCanLet.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
            //升序排序
            public int compare(Map.Entry<Integer, Integer> a,
                               Map.Entry<Integer, Integer> b) {
                int a1 = Math.abs(a.getKey() - a.getValue());
                int a2 = Math.abs(b.getKey() - b.getValue());
                if (a1 > a2) {
                    return 1;
                } else if (a1 < a2) {
                    return -1;
                } else return 0;
            }

        });
        // console.log(comCanLet);
        int ComChoose;//电脑选择棋子的编号
        //按位置逐一枚举
        for (int i = 0; i < list.size(); ++i) {
            int x = list.get(i).getKey(), y = list.get(i).getValue();
            for (int comi = 0; comi < 6; ++comi) {
                int[] DisCenterX = new int[5];
                int[] DisCenterY = new int[5];
                ;

                ComChoose = (int) (Math.floor(10 + Math.random() * (21 - 10 + 1)));
                //console.log('电脑选择的棋子' + ComChoose);

                if (comUsed[no][ComChoose] == true) {
                    continue;
                }

                switch (ComChoose) {
                    case 10:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = 0;
                        DisCenterY[4] = -2;
                        break;
                    case 11:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 12:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 13:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 14:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = -1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 15:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 1;
                        break;
                    case 16:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                    case 17:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 18:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 19:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 1;
                        DisCenterY[1] = 0;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 20:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 21:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                }
                //棋子中心点,从中心点扩展标记棋子
                for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                    for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                        //console.log('中心点'+qzx+' '+qzy);
                        if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法

                            //111111111原来棋子的方向顺时针旋转
                            for (int direct = 1; direct <= 8; ++direct) {
                                if (direct == 5) { //左右旋转尝试
                                    int[] tempZ;
                                    tempZ = DisCenterX;
                                    DisCenterX = LeftAndRightX(DisCenterX, DisCenterY);
                                    DisCenterY = LeftAndRightY(tempZ, DisCenterY);//旋转90度
                                }

                                int[] tempZ = new int[5];
                                tempZ = DisCenterX;
                                DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                boolean flagGai = false;//是否覆盖选择的x,y点
                                int illegal = 0;//中心点扩展棋子违规的点的数量


                                for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                    int tempx = qzx + DisCenterX[DCXi];
                                    int tempy = qzy + DisCenterY[DCXi];
                                    //console.log(tempx + ' ' + tempy);
                                    if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                        if (tempx == x && tempy == y) {
                                            flagGai = true;
                                        }
                                        if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                            if (
                                                    (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                            (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                            &&
                                                            (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                    (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                            &&
                                                            (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                    (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                            &&
                                                            (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                    (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                            ) {
                                                ;
                                            }
                                        } else {
                                            illegal++;
                                        }
                                    } else {
                                        illegal++;
                                    }
                                }

                                //能放!!!!!!!!!!!!!!!
                                if (flagGai && illegal == 0) {
                                    for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                        int tempx = qzx + DisCenterX[DCXi];
                                        int tempy = qzy + DisCenterY[DCXi];
                                        boxIndex[tempx][tempy] = piecesColor[no];
                                    }
                                    //画上，直接退出
                                    comUsed[no][ComChoose] = true;

                                    // drawChessBoard(boxIndex);
                                    return a;
                                }
                            }

                            //222222222左右翻转后，再顺时针旋转尝试  TODO

                        }
                    }
                }
            }
            //>>>>>>>>>>>>>>>>>>>>>>>>第二部分,如果随机方案不成功，从大到小遍历，谁合适就放谁
            if (!flag) {
                for (ComChoose = 21; ComChoose >= 1; --ComChoose) {
                    //console.log('选择棋子'+ComChoose)
                    int[] DisCenterX = new int[5];
                    int[] DisCenterY = new int[5];
                    if (comUsed[no][ComChoose] == false) {
                        switch (ComChoose) {
                            case 1:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                break;
                            case 2:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                break;
                            case 3:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                break;
                            case 4:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                break;
                            case 5:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                break;
                            case 6:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 7:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 8:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = -1;
                                DisCenterY[1] = -1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 9:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 10:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = 0;
                                DisCenterY[4] = -2;
                                break;
                            case 11:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 12:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 13:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 14:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 15:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 1;
                                break;
                            case 16:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                            case 17:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 18:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 19:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 1;
                                DisCenterY[1] = 0;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 20:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 21:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                        }

                        //棋子中心点,从中心点扩展标记棋子
                        for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                            for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                                //console.log('中心点'+qzx+' '+qzy);
                                if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法
                                    //1111111111原来棋子的方向顺时针旋转
                                    for (int direct = 1; direct <= 4; ++direct) {
                                        int tempZ[] = new int[5];
                                        tempZ = DisCenterX;
                                        DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                        DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                        boolean flagGai = false;//是否覆盖选择的x,y点
                                        int illegal = 0;//中心点扩展棋子违规的点的数量


                                        for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                            int tempx = qzx + DisCenterX[DCXi];
                                            int tempy = qzy + DisCenterY[DCXi];
                                            //console.log(tempx + ' ' + tempy);
                                            if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                                if (tempx == x && tempy == y) {
                                                    flagGai = true;
                                                }
                                                if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                                    if (
                                                            (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                                    (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                            (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                            (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                            (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                                    ) {
                                                        ;
                                                    }
                                                } else {
                                                    illegal++;
                                                }
                                            } else {
                                                illegal++;
                                            }
                                        }

                                        //能放!!!!!!!!!!!!!!!
                                        if (flagGai && illegal == 0) {
                                            for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                                int tempx = qzx + DisCenterX[DCXi];
                                                int tempy = qzy + DisCenterY[DCXi];
                                                boxIndex[tempx][tempy] = piecesColor[no];
                                            }
                                            //画上，直接退出
                                            comUsed[no][ComChoose] = true;

                                            // drawChessBoard(boxIndex);
                                            return a;
                                        }

                                    }

                                    //222222222左右翻转后，再顺时针旋转尝试  TODO

                                }
                            }
                        }
                    }
                }
            }
            //<<=<<<<<<<<<<<<<<<<<==========
        }
        a[no] = 1;
        return a;
    }

    private static int[] computerPlay4(int no, int[] a) {
        updateComBoxIndex(no);  //更新棋盘，更新xxx2 xxx3的点

        boolean flag = false;
        Map<Integer, Integer> comCanLet = new HashMap<Integer, Integer>();//电脑编号no能下的位置
        //找位置
        for (int i = 1; i <= 20; ++i) {
            for (int j = 1; j <= 20; ++j) {
                if (boxIndex[i][j] == canPosition[no]) {
                    //console.log(i,j);
                    comCanLet.put(i, j);
//                    comCanLet.push({x:i,y:j});
                }
            }
        }
        //排序
        List<Map.Entry<Integer, Integer>> list = new ArrayList<Map.Entry<Integer, Integer>>(comCanLet.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
            //升序排序
            public int compare(Map.Entry<Integer, Integer> a,
                               Map.Entry<Integer, Integer> b) {
                int a1 = Math.abs(a.getKey() - a.getValue());
                int a2 = Math.abs(b.getKey() - b.getValue());
                if (a1 > a2) {
                    return 1;
                } else if (a1 < a2) {
                    return -1;
                } else return 0;
            }

        });
        // console.log(comCanLet);
        int ComChoose;//电脑选择棋子的编号
        //按位置逐一枚举
        for (int i = 0; i < list.size(); ++i) {
            int x = list.get(i).getKey(), y = list.get(i).getValue();
            for (int comi = 0; comi < 6; ++comi) {
                int[] DisCenterX = new int[5];
                int[] DisCenterY = new int[5];
                ;

                ComChoose = (int) (Math.floor(10 + Math.random() * (21 - 10 + 1)));
                //console.log('电脑选择的棋子' + ComChoose);

                if (comUsed[no][ComChoose] == true) {
                    continue;
                }

                switch (ComChoose) {
                    case 10:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = 0;
                        DisCenterY[4] = -2;
                        break;
                    case 11:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 12:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 13:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 0;
                        break;
                    case 14:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = -1;
                        DisCenterY[2] = 0;
                        DisCenterX[3] = 0;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 15:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = -1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = 1;
                        break;
                    case 16:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                    case 17:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 18:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 19:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 1;
                        DisCenterY[1] = 0;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = -1;
                        DisCenterX[3] = 1;
                        DisCenterY[3] = 1;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 20:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -1;
                        DisCenterY[4] = -1;
                        break;
                    case 21:
                        DisCenterX[0] = 0;
                        DisCenterY[0] = 0;
                        DisCenterX[1] = 0;
                        DisCenterY[1] = 1;
                        DisCenterX[2] = 0;
                        DisCenterY[2] = 2;
                        DisCenterX[3] = -1;
                        DisCenterY[3] = 0;
                        DisCenterX[4] = -2;
                        DisCenterY[4] = 0;
                        break;
                }
                //棋子中心点,从中心点扩展标记棋子
                for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                    for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                        //console.log('中心点'+qzx+' '+qzy);
                        if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法

                            //111111111原来棋子的方向顺时针旋转
                            for (int direct = 1; direct <= 8; ++direct) {
                                if (direct == 5) { //左右旋转尝试
                                    int[] tempZ;
                                    tempZ = DisCenterX;
                                    DisCenterX = LeftAndRightX(DisCenterX, DisCenterY);
                                    DisCenterY = LeftAndRightY(tempZ, DisCenterY);//旋转90度
                                }

                                int[] tempZ = new int[5];
                                tempZ = DisCenterX;
                                DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                boolean flagGai = false;//是否覆盖选择的x,y点
                                int illegal = 0;//中心点扩展棋子违规的点的数量


                                for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                    int tempx = qzx + DisCenterX[DCXi];
                                    int tempy = qzy + DisCenterY[DCXi];
                                    //console.log(tempx + ' ' + tempy);
                                    if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                        if (tempx == x && tempy == y) {
                                            flagGai = true;
                                        }
                                        if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                            if (
                                                    (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                            (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                            &&
                                                            (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                    (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                            &&
                                                            (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                    (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                            &&
                                                            (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                    (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                            ) {
                                                ;
                                            }
                                        } else {
                                            illegal++;
                                        }
                                    } else {
                                        illegal++;
                                    }
                                }

                                //能放!!!!!!!!!!!!!!!
                                if (flagGai && illegal == 0) {
                                    for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                        int tempx = qzx + DisCenterX[DCXi];
                                        int tempy = qzy + DisCenterY[DCXi];
                                        boxIndex[tempx][tempy] = piecesColor[no];
                                    }
                                    //画上，直接退出
                                    comUsed[no][ComChoose] = true;

                                    // drawChessBoard(boxIndex);
                                    return a;
                                }
                            }

                            //222222222左右翻转后，再顺时针旋转尝试  TODO

                        }
                    }
                }
            }
            //>>>>>>>>>>>>>>>>>>>>>>>>第二部分,如果随机方案不成功，从大到小遍历，谁合适就放谁
            if (!flag) {
                for (ComChoose = 21; ComChoose >= 1; --ComChoose) {
                    //console.log('选择棋子'+ComChoose)
                    int[] DisCenterX = new int[5];
                    int[] DisCenterY = new int[5];
                    if (comUsed[no][ComChoose] == false) {
                        switch (ComChoose) {
                            case 1:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                break;
                            case 2:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                break;
                            case 3:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                break;
                            case 4:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                break;
                            case 5:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                break;
                            case 6:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 7:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 8:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = -1;
                                DisCenterY[1] = -1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                break;
                            case 9:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                break;
                            case 10:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = 0;
                                DisCenterY[4] = -2;
                                break;
                            case 11:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 12:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 13:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 0;
                                break;
                            case 14:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = -1;
                                DisCenterY[2] = 0;
                                DisCenterX[3] = 0;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 15:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = -1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = 1;
                                break;
                            case 16:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                            case 17:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 18:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 19:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 1;
                                DisCenterY[1] = 0;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = -1;
                                DisCenterX[3] = 1;
                                DisCenterY[3] = 1;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 20:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -1;
                                DisCenterY[4] = -1;
                                break;
                            case 21:
                                DisCenterX[0] = 0;
                                DisCenterY[0] = 0;
                                DisCenterX[1] = 0;
                                DisCenterY[1] = 1;
                                DisCenterX[2] = 0;
                                DisCenterY[2] = 2;
                                DisCenterX[3] = -1;
                                DisCenterY[3] = 0;
                                DisCenterX[4] = -2;
                                DisCenterY[4] = 0;
                                break;
                        }

                        //棋子中心点,从中心点扩展标记棋子
                        for (int qzx = x - 2; qzx <= x + 2; qzx++) {
                            for (int qzy = y - 2; qzy <= y + 2; qzy++) {
                                //console.log('中心点'+qzx+' '+qzy);
                                if (qzx >= 1 && qzx <= 20 && qzy >= 1 && qzy <= 20) { //中心点合法
                                    //1111111111原来棋子的方向顺时针旋转
                                    for (int direct = 1; direct <= 4; ++direct) {
                                        int tempZ[] = new int[5];
                                        tempZ = DisCenterX;
                                        DisCenterX = Xuan90X(DisCenterX, DisCenterY);
                                        DisCenterY = Xuan90Y(tempZ, DisCenterY);//旋转90度

                                        boolean flagGai = false;//是否覆盖选择的x,y点
                                        int illegal = 0;//中心点扩展棋子违规的点的数量


                                        for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                            int tempx = qzx + DisCenterX[DCXi];
                                            int tempy = qzy + DisCenterY[DCXi];
                                            //console.log(tempx + ' ' + tempy);
                                            if (tempx >= 1 && tempx <= 20 && tempy >= 1 && tempy <= 20) {
                                                if (tempx == x && tempy == y) {
                                                    flagGai = true;
                                                }
                                                if (boxIndex[tempx][tempy] == "0" || boxIndex[tempx][tempy] == canPosition[no]) {
                                                    if (
                                                            (tempy + 1 > 20 || (tempy + 1 <= 20 && (boxIndex[tempx][tempy + 1] == "0" ||
                                                                    (boxIndex[tempx][tempy + 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempy - 1 < 1 || (tempy - 1 >= 1 && (boxIndex[tempx][tempy - 1] == "0" ||
                                                                            (boxIndex[tempx][tempy - 1] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx + 1 > 20 || (tempx + 1 <= 20 && (boxIndex[tempx + 1][tempy] == "0" ||
                                                                            (boxIndex[tempx + 1][tempy] != piecesColor[no]))))
                                                                    &&
                                                                    (tempx - 1 < 1 || (tempx - 1 >= 1 && (boxIndex[tempx - 1][tempy] == "0" ||
                                                                            (boxIndex[tempx - 1][tempy] != piecesColor[no]))))
                                                    ) {
                                                        ;
                                                    }
                                                } else {
                                                    illegal++;
                                                }
                                            } else {
                                                illegal++;
                                            }
                                        }

                                        //能放!!!!!!!!!!!!!!!
                                        if (flagGai && illegal == 0) {
                                            for (int DCXi = 0; DCXi < DisCenterX.length; ++DCXi) {
                                                int tempx = qzx + DisCenterX[DCXi];
                                                int tempy = qzy + DisCenterY[DCXi];
                                                boxIndex[tempx][tempy] = piecesColor[no];
                                            }
                                            //画上，直接退出
                                            comUsed[no][ComChoose] = true;

                                            // drawChessBoard(boxIndex);
                                            return a;
                                        }

                                    }

                                    //222222222左右翻转后，再顺时针旋转尝试  TODO

                                }
                            }
                        }
                    }
                }
            }
            //<<=<<<<<<<<<<<<<<<<<==========
        }
        a[no] = 1;
        return a;
    }


}